zhead
All of the TypeScript definitions for <head>.
Powering Unhead.
Features
- 💎 Fully typed Head schema
- 💎 Commented with MDN docs
- 💎 Fully Augmentable
- 💎 100+ typed meta's
Installation
npm install --save-dev zhead
yarn add --dev zhead
Types
Head
Typescript base schema for document <head>.
export interface Head<E extends MergeHead = MergeHead> extends BaseHead {
title?: string
base?: Partial<Merge<E['base'], Base>>
link?: (Link & DataKeys & DefinedValueOrEmptyObject<E['link']>)[]
meta?: (Meta & DataKeys & DefinedValueOrEmptyObject<E['meta']>)[]
style?: (Style & DataKeys & DefinedValueOrEmptyObject<E['style']>)[]
script?: (Script & DataKeys & DefinedValueOrEmptyObject<E['script']>)[]
noscript?: (Noscript & DataKeys & DefinedValueOrEmptyObject<E['noscript']>)[]
htmlAttrs?: (HtmlAttributes & DataKeys & DefinedValueOrEmptyObject<E['htmlAttrs']>)
bodyAttrs?: (BodyAttributes & DataKeys & DefinedValueOrEmptyObject<E['bodyAttrs']>)
}
Flat Meta
See metaFlat.ts for the full list.
export interface MetaFlat {
charset: string
description: string
viewport: string | Partial<{
width: number | string | 'device-width'
height: number | string | 'device-height'
initialScale: number | string
maximumScale: number | string
minimumScale: number | string
userScalable: 'yes' | 'no'
viewportFit: 'auto' | 'contain' | 'cover'
}>
}
API
defineHead
Use this decorator for a simple fully-typed head schema.
import { defineHead } from 'zhead'
const head = defineHead({
title: 'My Page',
})
License
MIT License © 2022-PRESENT Harlan Wilton